package com.zhuss.job.processor;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.job.job.DeleteJobAppendBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.db.entity.OpLog;
import com.zhuss.enums.LogActionEnum;
import com.zhuss.enums.MoudleEnum;
import com.zhuss.exception.WpsException;
import com.zhuss.util.JsonUtil;
import com.zhuss.job.db.dao.ext.JobAppendDao;
import com.zhuss.job.db.entity.JobAppend;

/**
 * 删除职位Append processor
 * @Author: zhushanshuo
 * @Date: 2019/9/24 19:54
 */
@Component("jobAppendDelete")
public class JobAppendDelete extends AbstractProcessor<Object, DeleteJobAppendBo> implements Processor<Object, DeleteJobAppendBo> {

    @Autowired
    private JobAppendDao jobAppendDao;
    
    /**
     * 校验
     */
	@Override
    public void check(DeleteJobAppendBo bo) throws WpsException {
    	
    }
    
    /**
     * 操作方法
     */
    @Override
    public Object process(DeleteJobAppendBo param) throws WpsException {
    	Long jobAppendId = param.getJobAppendId();
    	
    	JobAppend record = new JobAppend();
    	record.setJobAppendId(jobAppendId);
    	record.setDeleted(param.getDeleted());
    	
    	record.setModifierId(param.getConcurrentUserId());
    	record.setModifier(param.getConcurrentUserName());
    	record.setModifyTime(new Date());
    	jobAppendDao.delete(record);
        return null;
    }
    
    /**
     * 操作日志
     */
	@Override
	public Object log(DeleteJobAppendBo param) throws WpsException {
		OpLog record = new OpLog();
    	record.setMoudle(MoudleEnum.职位.key());
    	record.setAction(LogActionEnum.职位Append删除.key());
    	record.setTargetId(param.getJobAppendId());
    	record.setTargetName(param.getJobAppendId() + "");
    	record.setContent("参数: " + JsonUtil.toJson(param));
    	record.setReason(param.getExceptionReason());
    	
    	record.setCreatorId(param.getConcurrentUserId());
    	record.setCreator(param.getConcurrentUserName());
    	record.setCreateTime(new Date());
    	log(record);
    	return null;
	}
}
